<template>
	<view class="app">
		<view class="box1">
			<uni-data-select class="section1"></uni-data-select>
			<uni-search-bar @confirm="getIndex" @clear="getIndex1" :focus="true" v-model="search" cancelButton="none"
				class="search">
			</uni-search-bar>
			<button class="butt1" type="primary" @click="getIndex">搜索</button>
		</view>
		<view class="box2">
			<uni-notice-bar show-icon scrollable text="用户156****6868已完成14单，累计获得佣金71元。" />
		</view>
		<view>
			<uni-row class="renwu">
				<uni-col :span="12">
					<view @click="goFabu()" class="renwu-butt" style="float: left;">
						发布任务
					</view>
				</uni-col>
				<uni-col :span="12">
					<view @click="goRW()" class="renwu-butt" style="float: left;">任务中心</view>
				</uni-col>
			</uni-row>
		</view>
		<view class="list">
			<uni-data-checkbox v-model="radio1" :localdata="sex" @change="changePaiXv"></uni-data-checkbox>
			<uni-card v-for="item in tableList" :key="item.id" :title="item.title" :extra="'佣金' + item.yongjin + '元'" class="listItem"
				@click="goXq(item)">
				<text class="uni-body">支付方式:{{item.qudao}}<br />
					时间:{{item.dateTime}}&emsp;剩余笔数:{{item.geshu}}
					<!-- <cover-image :src="'http://127.0.0.1:8089/intool/' + item.images"></cover-image> -->
				</text>
			</uni-card>
		</view>
	</view>
</template>

<script>
	import {
		baseDefaultUrl
	} from '../../config/config'
	export default {
		onShow() {
			this.getList()
		},
		data() {
			return {
				tableList: [],
				search: '',
				radio1: 0,
				sex: [{
					text: '按时间排序',
					value: 0
				}, {
					text: '按佣金排序',
					value: 1
				}],
			}
		},
		methods: {
			getIndex() {
				uni.request({
					url: baseDefaultUrl + "/inter/t-work/list",
					method: 'GET',
					data: {
						"paixv": this.radio1,
						"sou": this.search
					},
					header: {
						"Authorization": uni.getStorageSync('token')
					},
					success: (res) => {
						if (res.data.code != 0) {
							this.tableList = res.data.data
						} else {
							alert(res.data.message)
						}
					}
				})
			},
			getIndex1() {
				this.search = ''
				uni.request({
					url: baseDefaultUrl + "/inter/t-work/list",
					method: 'GET',
					data: {
						"paixv": this.radio1,
						"sou": this.search
					},
					header: {
						"Authorization": uni.getStorageSync('token')
					},
					success: (res) => {
						if (res.data.code != 0) {
							this.tableList = res.data.data
						} else {
							alert(res.data.message)
						}
					}
				})
			},
			goFabu() {
				uni.navigateTo({
					url: '/pages/fabu/fabu'
				})
			},
			goXq(params) {
				uni.navigateTo({
					url: '/pages/xq/xq?id=' + params.id
				})
			},
			goRW() {
				uni.navigateTo({
					url: '/pages/rwcenter/rwcenter'
				})
			},
			getList() {
				uni.request({
					url: baseDefaultUrl + "/inter/t-work/list",
					method: 'GET',
					data: {
						"paixv": this.radio1,
						"sou": this.search
					},
					header: {
						"Authorization": uni.getStorageSync('token')
					},
					success: (res) => {
						if (res.data.code != 0) {
							this.tableList = res.data.data
						} else {
							alert(res.data.message)
						}
					}
				})
			},
			changePaiXv() {
				uni.request({
					url: baseDefaultUrl + "/inter/t-work/list",
					method: 'GET',
					data: {
						"paixv": this.radio1,
						"sou": this.search
					},
					header: {
						"Authorization": uni.getStorageSync('token')
					},
					success: (res) => {
						if (res.data.code != 0) {
							this.tableList = res.data.data
						} else {
							alert(res.data.message)
						}
					}
				})
			}
		}
	}
</script>

<style scoped>
	.app {
		padding: 20rpx;
	}

	.uni-input {
		background: #fff;
		width: 40%;
		height: 30rpx;
		border: 1px solid rgba(0, 0, 0, 0.1);
		border-radius: 30rpx;
		float: left;
	}

	.butt1 {
		float: left;
		height: 60rpx;
		font-size: 30rpx;
		line-height: 60rpx;
		margin: 5rpx 10rpx;
		border-radius: 30rpx;
	}

	.tongzhi {
		float: right;
		width: 50rpx;
		height: 50rpx;
		margin-top: 10rpx;
	}


	.section1 {
		float: left;
		width: 150rpx;
		margin-right: 10rpx;
	}

	.box1 {
		height: 80rpx;
	}

	.box2 {
		margin-top: 10rpx;
	}

	.renwu-butt {
		width: 96%;
		height: 120rpx;
		line-height: 120rpx;
		text-align: center;
		font-size: 42rpx;
		/* border: 1px solid rgba(0, 0, 0, 0.1); */
		border-radius: 30rpx;
		background: linear-gradient(#007aff, #4596ff);
		color: #fff;
		box-shadow: 0 5px 7px rgba(0, 0, 0, 0.1);
	}

	.renwu {
		margin-top: 10rpx;
	}

	.list {
		margin-top: 30rpx;
	}

	.listItem {
		margin: 20rpx 0;
	}

	.search {
		padding: 0;
		float: left;
		width: 50%;
	}
</style>